/*
 * main.cpp
 *
 *  Created on: Sep 8, 2009
 *      Author: mlrus
 */
#undef _mainBOARD
#include <iostream>
#include <fstream>
#include <string>

#include "GamestateWriter.h"

#include "cmdListener.h"

#include "common/Socket.h"

using namespace std;

#ifdef _mainBOARD
int main(int argc, char **argv) {

    tilemessage::GameState gs;
    tilemessage::SolutionSet sol;
    GamestateWriter::GamestateWriter gsw;

   const char *protobuffStore = "/tmp/sample.proto";
   const char *processorHost = "127.0.0.1";
    int port = 8001;
    startCmdListener(8001);
    sleep(1);
    int argcnt = 1;
    if(argc>argcnt)protobuffStore = argv[argcnt++];
    if(argc>argcnt)processorHost = argv[argcnt++];
    if(argc>argcnt)port = atoi(argv[argcnt++]);


    Socket socket;
    socket.sendFilecontent(protobuffStore, processorHost, port);
    while(argcnt<argc) {
        std::string sourcefile(argv[argcnt++]);
        std::string destfile(sourcefile+".dest");
        cout << "Read from " << sourcefile << endl;
        gsw.readState(&gs,sourcefile);
        gsw.showState(gs);
        gsw.doWrite(gs,destfile);
    }

    gsw.PromptForGamestate(&gs);
    gsw.showState(gs);
    gsw.doWrite(gs,"/tmp/sample.proto");

    gsw.generateDummySolution(&sol);
    gsw.generateDummySolution(&sol);
    gsw.showSolution(sol);


    sleep(2);
    // Optional:  Delete all global objects allocated by libprotobuf.
    google::protobuf::ShutdownProtobufLibrary();

}
#endif
